package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.product.ProductProductCombineAddRequest;
import com.mes.cloud.api.dto.request.product.ProductProductCombineEnableRequest;
import com.mes.cloud.api.dto.request.product.ProductProductCombinePageRequest;
import com.mes.cloud.api.dto.response.product.ProductProductCombinePageDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.ProductProductCombineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author xy
 * @version 2019-08-23 10:37:15
 * @email yuan.xue3@pactera.com
 */
@Api(tags = "产品组合关联", value = "产品组合关联接口")
@RestController
@RequestMapping(value = "/productProductCombine")
public class ProductProductCombineController {

    private ProductProductCombineService productProductCombineService;

    @Autowired
    public ProductProductCombineController(ProductProductCombineService productProductCombineService) {
        this.productProductCombineService = productProductCombineService;
    }

    /**
     * 功能: 产品组合关联分页查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager<ProductProductCombineDto>>
     */
    @ApiOperation(value = "产品组合关联分页查询", notes = "产品组合关联分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<ProductProductCombinePageDto>> pageList(@Valid @RequestBody ProductProductCombinePageRequest pageRequest) {
        return productProductCombineService.pageList(pageRequest);
    }


    /**
     * 功能: 产品组合关联新增
     *
     * @param productProductCombineRequest
     * @return JsonResult
     */
    @ApiOperation(value = "新增产品组合关联", notes = "新增产品组合关联")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody ProductProductCombineAddRequest productProductCombineRequest) {
        return productProductCombineService.add(productProductCombineRequest);
    }

    /**
     * 功能: 产品组合移除关联
     *
     * @param productProductCombineEnableRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品组合移除关联", notes = "产品组合移除关联")
    @PostMapping(value = "/updateEnableFlag")
    public JsonResult updateEnableFlag(@Valid @RequestBody ProductProductCombineEnableRequest productProductCombineEnableRequest) {
        return productProductCombineService.updateEnableFlag(productProductCombineEnableRequest);
    }
}
